package com.ysw.spring.api_security.md5;

import cn.hutool.crypto.digest.DigestUtil;
import cn.hutool.crypto.digest.MD5;
import org.springframework.util.DigestUtils;

/**
 * @ClassName Demo
 * @Description md5 工具类
 * @Author ysw
 * @Date 2022/4/22 19:40
 */
public class Demo {
    public static void main(String[] args) {
        String name = "dw你好达瓦达dwdwwddwfffww瓦达瓦fwfwfwvvejiij你好都叫我i读完i的 ";
        String md516 = Md5Util.getMd516(name);
        String md516Spring = Md5Util.getMd516Spring(name);
        System.out.println(md516 + "\n" + md516Spring);

    }

    public static class Md5Util{

        /**
         * hutool 工具类
         * @param str
         * @return
         */
        public static String getMd516(String str){
            String s = DigestUtil.md5Hex(str);
            return s;
        }

        public static String getMd516Spring(String str){
            String s = DigestUtils.md5DigestAsHex(str.getBytes());
            return s;
        }

    }
}